package com.example.myblog.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//这个注解表示这是个配置文件，将随着spring的启动而同时启动
@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    private loginInterceptor interceptor;
    //表示当用户未登录的状态可以看到的页面
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor).addPathPatterns("/**")//拦截所有url地址
                                            .excludePathPatterns("/login.html")
                                            .excludePathPatterns("/reg.html")
                                            .excludePathPatterns("/blog_list.html")
                                            .excludePathPatterns("/blog_content.html")
                                            .excludePathPatterns("/css/**")
                                            .excludePathPatterns("/editor.md/**")
                                            .excludePathPatterns("/img/**")
                                            .excludePathPatterns("/js/**")
                                            .excludePathPatterns("/user/login")
                                            .excludePathPatterns("/user/reg")
                                            .excludePathPatterns("/user/islogin")
                                            .excludePathPatterns("/article/getdetail")
                                            .excludePathPatterns("/article/addrcount")
                                            .excludePathPatterns("/article/getcount")
                                            .excludePathPatterns("/article/getlistbypage");
    }
}
